package cc.autoapi.pucong.auto.flow.core.root.selfenum;


import com.fasterxml.jackson.annotation.JsonCreator;


/**
 * 通用是否枚举类
 *
 * @author pucong
 */
public enum CommonBoolenEnum implements CommonEnum<Integer> {

    否(0, "否"),
    是(1, "是");

    private Integer key;

    private String desc;

    CommonBoolenEnum(Integer key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    /**
     * 字典code
     *
     * @return
     */
    @Override
    public Integer getValue() {
        return this.key;
    }

    /**
     * 字典名称
     *
     * @return
     */
    @Override
    public String getName() {
        return this.name();
    }

    @JsonCreator
    public static CommonBoolenEnum getItemByValue(Integer value) {
        CommonBoolenEnum[] itemArr = CommonBoolenEnum.values();
        if (value != null) {
            for (CommonBoolenEnum item : itemArr) {
                if (value.equals(item.getValue())) {
                    return item;
                }
            }
        }
        return null;
    }
}
